import request from '@/utils/request'

// 查询ZxDesign列表
export function listZxDesign(query) {
  return request({
    url: '/api/v1/zxdesignList',
    method: 'get',
    params: query
  })
}

// 查询ZxDesign详细
export function getZxDesign(id) {
  return request({
    url: '/api/v1/zxdesign/one/' + id,
    method: 'get'
  })
}

// 查询ZxDesign图
export function getImages(id) {
  return request({
    url: '/api/v1/zxdesign/images/' + id,
    method: 'get'
  })
}

// 删除ZxDesign图
export function removeImageFile(id, name) {
  return request({
    url: '/api/v1/zxdesign/removeImages/' + id + '/' + name,
    method: 'post'
  })
}

// 新增ZxDesign
export function addZxDesign(data) {
  data.designPrice = data.designPrice * 100
  return request({
    url: '/api/v1/zxdesign',
    method: 'post',
    data: data
  })
}

// 修改ZxDesign
export function updateZxDesign(data) {
  data.designPrice = data.designPrice * 100
  return request({
    url: '/api/v1/zxdesign',
    method: 'put',
    data: data
  })
}

// 删除ZxDesign
export function delZxDesign(id) {
  return request({
    url: '/api/v1/zxdesign/' + id,
    method: 'delete'
  })
}
export function doMoneyFormat(data) {
  // 获取单元格数据
  if (data == null || data == 0) {
    return ''
  }
  const realVal = parseFloat(data).toFixed(2)
  return parseFloat(realVal) / 100
}

export function doDateFormat(data) {
  // 获取单元格数据
  if (data == null || data == '0001-01-01T00:00:00Z') {
    return null
  }
  const dt = new Date(data)
  return dt.getFullYear() + '-' + (dt.getMonth() + 1) + '-' + dt.getDate()
  // return dt.getFullYear() + '-' + (dt.getMonth() + 1) + '-' + dt.getDate() + ' ' + dt.getHours() + ':' + dt.getMinutes() + ':' + dt.getSeconds()
}
